<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<div id="app">
    <h1>全名： {{fullName}} </h1>
    <h1>firstName： {{firstName}} </h1>
    <h1>lastName： {{lastName}} </h1>
</div>
</body>
<script src="../../js/vue.js"></script>
<script>
    var vm = new Vue({
        el: '#app',
        data: {
            firstName: '许',
            lastName: '墨'
        },
        computed: {
            fullName: {
                // getter
                get: function () {
                    return this.firstName + ' ' + this.lastName
                },
                // setter
                set: function (newValue) {
                    var names = newValue.split(' ')
                    this.firstName = names[0]
                    this.lastName = names[names.length - 1]
                }
            }
        }
    })
</script>
</html>
